 <?php
 if (isset($_COOKIE['loginperson'])) {
     setcookie("loginperson", "", time() - 3600); 
 }  
 ?>
 <!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>安装程序</title>
    <style>
       body {
    font-family: 'SF Pro Display', 'SF Pro Text', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; 
    background-color: #121212; 
    color: #f0f0f0; 
}

.container {
    width: 80%;
    margin: 0 auto;
    background-color: #282c34; 
    padding: 20px;
    border-radius: 10px; 
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #82b1ff; 
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5); 
}

label, input[type="text"], input[type="password"], button {
    display: block;
    margin: 0 auto 10px; 
    text-align: center; 
}

input[type="text"], input[type="password"] {
    padding: 10px; 
    border: none;
    border-bottom: 2px solid #82b1ff; 
    background-color: transparent; 
    color: #f0f0f0; 
    font-size: 16px; 
    transition: border-color 0.3s ease; 
}

input[type="text"]:focus, input[type="password"]:focus {
    border-bottom-color: #fff; 
}

button {
    width: 100%;
    display: block; 
    padding: 15px 20px; 
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 5px; 
    cursor: pointer;
    transition: background-color 0.3s ease; 
}

button:hover {
    background-color: #0056b3;
}

button:active {
    background-color: #004085; 
}
    </style>
</head>
<body>
    <div class="container">
        <h1>安装程序</h1>
        <form id="step1Form">
            <label for="dbHost">数据库主机：</label>
            <input type="text" id="dbHost" name="dbHost" value="localhost"><br><br>
            <label for="dbName">数据库名称：</label>
            <input type="text" id="dbName" name="dbName"><br><br>
            <label for="dbUsername">用户名：</label>
            <input type="text" id="dbUsername" name="dbUsername"><br><br>
            <label for="dbPassword">密码：</label>
      <input type="password" id="dbPassword" name="dbPassword"><br><br>
            <button type="button" onclick="nextStep(1)">完成安装</button>
        </form>
    </div>
   <script>  
          function nextStep(step) {    
              var xhr = new XMLHttpRequest();    
              var dbHost = document.getElementById('dbHost').value;      
              var dbName = document.getElementById('dbName').value;      
              var dbUsername = document.getElementById('dbUsername').value;      
              var dbPassword = document.getElementById('dbPassword').value;           
              if (dbHost === '' || dbName === '' || dbUsername === '' || dbPassword === '') {    
                  alert('所有字段都必须填写！');      
                  return;     
              }           
              xhr.open("POST", "call.php", true);    
              xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");    
              xhr.onreadystatechange = function() {  
                  if (xhr.readyState === 4) {   
                      if (xhr.status === 200) {   
                      if (xhr.responseText.includes("success")) {   
						  document.cookie = "loginperson=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; 
                            document.cookie = "installilon=value; expires=Fri, 31 Dec 2033 23:59:59 GMT; path=/"; 
                             window.location.href = './iacp.php'; 			  
                          } else {     
                              alert("Install error: " + xhr.responseText);   
                          }    
                      } else {     
                          alert("请求发生错误");   
                      }    
                  }    
              };    
              xhr.send("dbHost=" + dbHost + "&dbName=" + dbName + "&dbUsername=" + dbUsername + "&dbPassword=" + dbPassword);     
          }	     
   </script>
</body>
</html>